home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 3.iso / dist / fw_bind.idb / usr / freeware / include / bind / isc / dst.h.z / dst.h
Encoding:
C/C++ Source or Header  |  2001-04-12  |  4.7 KB  |  142 lines

  1. #ifndef DST_H
  2. #define DST_H
  3.  
  4. #ifndef HAS_DST_KEY
  5. typedef struct dst_key {
  6.     char    *dk_key_name;   /* name of the key */
  7.     int    dk_key_size;    /* this is the size of the key in bits */
  8.     int    dk_proto;       /* what protocols this key can be used for */
  9.     int    dk_alg;         /* algorithm number from key record */
  10.     u_int32_t dk_flags;     /* and the flags of the public key */
  11.     u_int16_t dk_id;        /* identifier of the key */
  12. } DST_KEY;
  13. #endif /* HAS_DST_KEY */
  14.  
  15. /* 
  16.  * DST Crypto API defintions 
  17.  */
  18. void     dst_init(void);
  19. int      dst_check_algorithm(const int);
  20.  
  21. int dst_sign_data(const int mode,     /* specifies INIT/UPDATE/FINAL/ALL */
  22.           DST_KEY *in_key,     /* the key to use */
  23.           void **context,     /* pointer to state structure */
  24.           const u_char *data,     /* data to be signed */
  25.           const int len,     /* length of input data */
  26.           u_char *signature,     /* buffer to write signature to */
  27.           const int sig_len);     /* size of output buffer */
  28.  
  29. int dst_verify_data(const int mode,     /* specifies INIT/UPDATE/FINAL/ALL */
  30.             DST_KEY *in_key,     /* the key to use */
  31.             void **context,     /* pointer to state structure */
  32.             const u_char *data,  /* data to be verified */
  33.             const int len,     /* length of input data */
  34.             const u_char *signature,/* buffer containing signature */
  35.             const int sig_len);     /* length of signature */
  36.  
  37.  
  38. DST_KEY *dst_read_key(const char *in_name,   /* name of key */
  39.               const u_int16_t in_id, /* key tag identifier */
  40.               const int in_alg,      /* key algorithm */
  41.               const int key_type);   /* Private/PublicKey wanted*/
  42.  
  43. int      dst_write_key(const DST_KEY *key,  /* key to write out */
  44.                const int key_type); /* Public/Private */
  45.  
  46. DST_KEY *dst_dnskey_to_key(const char *in_name,    /* KEY record name */
  47.                const u_char *key,    /* KEY RDATA */
  48.                const int len);    /* size of input buffer*/
  49.  
  50.  
  51. int      dst_key_to_dnskey(const DST_KEY *key,    /* key to translate */
  52.                u_char *out_storage,    /* output buffer */
  53.                const int out_len);    /* size of out_storage*/
  54.  
  55.  
  56. DST_KEY *dst_buffer_to_key(const char *key_name,  /* name of the key */
  57.                const int alg,      /* algorithm */
  58.                const int flags,      /* dns flags */
  59.                const int protocol,      /* dns protocol */
  60.                const u_char *key_buf, /* key in dns wire fmt */
  61.                const int key_len);      /* size of key */
  62.  
  63.  
  64. int     dst_key_to_buffer(DST_KEY *key, u_char *out_buff, int buf_len);
  65.  
  66. DST_KEY *dst_generate_key(const char *name,    /* name of new key */
  67.               const int alg,       /* key algorithm to generate */
  68.               const int bits,      /* size of new key */
  69.               const int exp,       /* alg dependent parameter*/
  70.               const int flags,     /* key DNS flags */
  71.               const int protocol); /* key DNS protocol */
  72.  
  73. DST_KEY *dst_free_key(DST_KEY *f_key);
  74. int      dst_compare_keys(const DST_KEY *key1, const DST_KEY *key2);
  75.  
  76. int    dst_sig_size(DST_KEY *key);
  77.  
  78. int     dst_random(const int mode, int wanted, u_char *outran);
  79.  
  80.  
  81. /* support for dns key tags/ids */
  82. u_int16_t dst_s_dns_key_id(const u_char *dns_key_rdata, const int rdata_len);
  83. u_int16_t dst_s_id_calc(const u_char *key_data, const int key_len);
  84.  
  85. /* Used by callers as well as by the library.  */
  86. #define RAW_KEY_SIZE    8192        /* large enough to store any key */
  87.  
  88. /* DST_API control flags */
  89. /* These are used used in functions dst_sign_data and dst_verify_data */
  90. #define SIG_MODE_INIT        1  /* initalize digest */
  91. #define SIG_MODE_UPDATE        2  /* add data to digest */
  92. #define SIG_MODE_FINAL        4  /* generate/verify signature */
  93. #define SIG_MODE_ALL        (SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL)
  94.  
  95. /* Flags for dst_read_private_key()  */
  96. #define DST_FORCE_READ        0x1000000
  97. #define DST_CAN_SIGN        0x010F
  98. #define DST_NO_AUTHEN        0x8000
  99. #define DST_EXTEND_FLAG         0x1000
  100. #define DST_STANDARD        0
  101. #define DST_PRIVATE             0x2000000
  102. #define DST_PUBLIC              0x4000000
  103. #define DST_RAND_SEMI           1
  104. #define DST_RAND_STD            2
  105. #define DST_RAND_KEY            3
  106. #define DST_RAND_DSS            4
  107.  
  108.  
  109. /* DST algorithm codes */
  110. #define KEY_RSA            1
  111. #define KEY_DH            2
  112. #define KEY_DSA            3
  113. #define KEY_PRIVATE        254
  114. #define KEY_EXPAND        255
  115. #define KEY_HMAC_MD5        157
  116. #define KEY_HMAC_SHA1        158
  117. #define UNKNOWN_KEYALG        0
  118. #define DST_MAX_ALGS            KEY_HMAC_SHA1
  119.  
  120. /* DST constants to locations in KEY record  changes in new KEY record */
  121. #define DST_FLAGS_SIZE        2
  122. #define DST_KEY_PROT        2
  123. #define DST_KEY_ALG        3
  124. #define DST_EXT_FLAG            4
  125. #define DST_KEY_START        4
  126.  
  127. #ifndef SIGN_F_NOKEY 
  128. #define SIGN_F_NOKEY        0xC000
  129. #endif
  130.  
  131. /* error codes from dst routines */
  132. #define SIGN_INIT_FAILURE    (-23)
  133. #define SIGN_UPDATE_FAILURE    (-24)
  134. #define SIGN_FINAL_FAILURE    (-25)
  135. #define VERIFY_INIT_FAILURE    (-26)
  136. #define VERIFY_UPDATE_FAILURE    (-27)
  137. #define VERIFY_FINAL_FAILURE    (-28)
  138. #define MISSING_KEY_OR_SIGNATURE (-30)
  139. #define UNSUPPORTED_KEYALG    (-31)
  140.  
  141. #endif /* DST_H */
  142.